import { createRouter, createWebHashHistory } from 'vue-router'
import type { RouteRecordRaw } from 'vue-router'
import layout from '../views/body/index.vue'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'layout',
      component: layout,
      meta: { title: '首页' },
      redirect: '/dataView',
      children: [
        import.meta.glob('./dataView.ts', { import: 'default', eager: true })['./dataView.ts'] as RouteRecordRaw,
        // import.meta.glob('./richText.js', { import: 'default', eager: true })['./richText.js'],
        // import.meta.glob('./classify.js', { import: 'default', eager: true })['./classify.js'],
        // import.meta.glob('./table.js', { import: 'default', eager: true })['./table.js'],
        // import.meta.glob('./execl.js', { import: 'default', eager: true })['./execl.js'],
        // import.meta.glob('./map.js', { import: 'default', eager: true })['./map.js'],
        // import.meta.glob('./news.js', { import: 'default', eager: true })['./news.js'],
        // import.meta.glob('./tree.js', { import: 'default', eager: true })['./tree.js'],
        {
          path: '/:pathMatch(.*)*',
          name: 'NotFound',
          component: () => import('../views/common/404.vue'),
        }
      ],
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/common/login.vue'),
    }
  ],
  scrollBehavior: () => ({ left: 0, top: 0 })
})

export default router
